# -*- coding: utf-8 -*-
from datetime import timedelta
from utils.operators.spark_submit import SparkSubmitOperator

from jms_hi.dwd.tms.dwd_tmsnew_shipment_union_base_hi import jms_dwd__dwd_tmsnew_shipment_union_base_hi
from jms_hi.dwd.tms.dwd_tmsnew_shipment_stop_union_base_hi import jms_dwd__dwd_tmsnew_shipment_stop_union_base_hi
from jms_hi.dwd.tab.dwd_tab_barscan_loading_base_hi import jms_dwd__dwd_tab_barscan_loading_base_hi
from jms_hi.dwd.tab.dwd_tab_barscan_unloading_base_hi import jms_dwd__dwd_tab_barscan_unloading_base_hi

jms_hi_dm__dm_shipment_stop_billcode_detail_dt  = SparkSubmitOperator(
    task_id='jms_hi_dm__dm_shipment_stop_billcode_detail_dt',
    email=['guoruiling@jtexpress.com','yl_bigdata@yl-scm.com'],
    name='jms_hi_dm__dm_shipment_stop_billcode_detail_dt_{{ execution_date | cst_ds }}',
    pool_slots=3,
    retries=1,
    depends_on_past=True,
    driver_memory='5G' , 
    executor_memory='4G' , 
    executor_cores=4 , 
    num_executors=14 , 
    yarn_queue='pro',
    conf={'spark.dynamicAllocation.enabled': 'true',  # 动态资源开启
          'spark.shuffle.service.enabled': 'true',  # 动态资源 Shuffle 服务开启
        'spark.dynamicAllocation.maxExecutors'             : 17 , 
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 60,  # 动态资源自动释放闲置 Executor 的超时时间(s)
          'spark.sql.sources.partitionOverwriteMode': 'dynamic',  # 允许删改已存在的分区
        'spark.executor.memoryOverhead'             : '2G' , 
          'spark.default.parallelism': 300,
          'spark.sql.shuffle.partitions': 320
          },
    jars='hdfs:///scheduler/jms/spark/grl/dm_shipment_stop_billcode_detail_dt/common-1.0-SNAPSHOT.jar',  # 依赖 jar 包
    java_class='com.yunlu.bigdata.jobs.export.ExportFIOShipmentStopBillcodeDetailHI',  # spark 主类
    application='hdfs:///scheduler/jms/spark/grl/dm_shipment_stop_billcode_detail_dt/original-jobs-1.0-SNAPSHOT.jar',
    # spark jar 包
    application_args=['{{ execution_date | cst_ds }}'],
    execution_timeout=timedelta(hours=3)
)

jms_hi_dm__dm_shipment_stop_billcode_detail_dt  << [
    jms_dwd__dwd_tmsnew_shipment_union_base_hi,
    jms_dwd__dwd_tmsnew_shipment_stop_union_base_hi,
    jms_dwd__dwd_tab_barscan_loading_base_hi,
    jms_dwd__dwd_tab_barscan_unloading_base_hi,

]
 